import React from 'react';
import { withRouter } from 'react-router-dom';
import { RouteLayout } from 'weaver-mobile-page';
import { Tools } from 'weaver-mobile';

@withRouter
export default class Main extends React.Component{
    constructor(props){
        super(props);
    }
    render(){
        const { location } = this.props;
        const src = location && location.iframeUrl || "";
        const isPhone = Tools.mobileDetect().is("iPhone");
        let style = {width:"100%", height:"100%", border:"none"};
        let iframeProps = {};
        if(isPhone){
            iframeProps = {scrolling:"no"};
            style = {...style, ...{width:"100%", minWidth:"100%",minHeight:"100%"}};
        }
        let className="wm-route-layout wf-req-hoverWindow";
        if(src.includes("/spa/document")){
            className += ` wf-doc-open-attach`
        }
        return (
            <RouteLayout>
                <div key="hoverWindow" className={className}>
                    <iframe id="__hoverIframe" style={style} src={src} {...iframeProps} />
                </div>
            </RouteLayout>
        )
    }
}